package cn.chencq.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import cn.chencq.interceptor.GateWayInterceptor;

/**
 * 
 * 拦截器配置
 * 
 * @author chencq
 * @email chenchaoqun@incar100.com
 * @date 2018-3-14 下午6:34:39
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(gateWayInterceptor()).addPathPatterns("/**");
		super.addInterceptors(registry);
	}

	@Bean // 将自定义拦截器注册到spring bean中
	public GateWayInterceptor gateWayInterceptor() {
		return new GateWayInterceptor();
	}
}